<?php
class admin_helpers_editList extends Zend_View_Helper_Abstract
{
	/**
	 * @var Engine_Core_Collection
	 */
	protected $_collection;

	/**
	 * @var string
	 */
	protected $_markup = '/';


	/**
	 * @param Engine_Core_Collection $collection
	 * @param array $fields
	 * @param string $markup
	 * @return string
	 */
	public function editList($collection, $fields, $markup)
	{
		if (empty($collection) || !$collection->count()) {
			return;
		}

		$this->_markup    .= $markup;

		foreach($collection->items() as $entry) {
			$rows[] = $this->view->editRow($entry, $fields, $markup);
		}

		return $this->view->partial('templates/editRow' . $this->_markup . '/drawList.phtml', array(
			'rows' => $rows,
			'fields' => $fields,
			'header' => $this->view->partial('templates/editRow' . $this->_markup . '/drawHeader.phtml', array(
				'fields' => $fields,
			)),
			'footer' => $this->view->partial('templates/editRow' . $this->_markup . '/drawFooter.phtml'),
		));
	}
}